﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JOIN.Right.SSOLib.AuthService;

namespace JOIN.Rights.SSOLib
{
    /// <summary>
    /// 单点登录校验校验
    /// </summary>
    public class AuthUtil
    {
        JOIN.Right.SSOLib.AuthService.AuthServiceSoapClient Service = new Right.SSOLib.AuthService.AuthServiceSoapClient();

        private static AuthUtil instance;
        public static AuthUtil Instance
        {
            get 
            {
                if (instance == null)
                    instance = new AuthUtil();
                return instance;
            }
        }
        /// <summary>
        /// 校验用户登录
        /// </summary>
        /// <param name="userNO">帐号</param>
        /// <param name="pwd">密码</param>
        /// <param name="projectID">系统ID</param>
        /// <returns></returns>
        public ServiceResultOfOnlineUserInfo AuthUser(string userNO, string pwd, string projectID)
        {
            return Service.Authenticate(userNO, pwd, projectID);
        }
        /// <summary>
        /// 获取菜单
        /// </summary>
        /// <param name="tokenID">会话ID</param>
        /// <returns></returns>
        public MenusInfo[] GetMenus(string tokenID)
        {
            MenusInfo[] list=Service.GetMenus(tokenID);
            return list;
        }
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="userNO">帐号</param>
        /// <param name="oldPwd">旧密码</param>
        /// <param name="newPwd">新密码</param>
        /// <returns></returns>
        public ServiceResultOfUserInfo ChangePassword(string userNO, string oldPwd, string newPwd)
        {
            return Service.ChangePassword(userNO, oldPwd, newPwd);
        }

    }
}
